package com.fanfan.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class PageController {

	@RequestMapping("{module}/{url}.html")
	public ModelAndView module(@PathVariable("module") String module, @PathVariable("url") String url, @RequestParam(value = "param",required = false)String param){
		ModelAndView mav = new ModelAndView(module + "/" + url);
		mav.addObject("param",param==null?"":param);

		return mav;
	}

	@RequestMapping("{url}.html")
	public String url(@PathVariable("url") String url){
		return url;
	}

	@RequestMapping("/")
	public String index(){
		return "index.html";
	}
}
